Javascript Program For Rearranging An Array In Maximum Minimum Form – Set 2 (O(1) extra space)
Given a sorted array of positive integers, rearrange the array alternately i.e first element should be the maximum value, second minimum value, third-second max, fourth-second min and so on. Examples:...
read more
Javascript Program for Products of ranges in an array
Given an array A[] of size N. Solve Q queries. Find the product in the range [L, R] under modulo P ( P is Prime)....
read more
Php Program For Rearranging An Array In Maximum Minimum Form – Set 2 (O(1) extra space)
Given a sorted array of positive integers, rearrange the array alternately i.e first element should be the maximum value, second minimum value, third-second max, fourth-second min and so on. Examples:...
read more
Javascript Program To Multiply Two Numbers Represented By Linked Lists
Given two numbers represented by linked lists, write a function that returns the multiplication of these two linked lists....
read more
Generate Array whose sum of all K-size subarrays divided by N leaves remainder X
Given three integer N, K and X, the task is to create an array of length N such that sum of all its K-length subarrays modulo N is X.Examples:...
read more
Print last k digits of a^b (a raised to power b)
Given positive integers k, a and b we need to print last k digits of a^b ie.. pow(a, b)....
read more
Padovan Sequence
Padovan Sequence similar to Fibonacci sequence with similar recursive structure. The recursive formula is,...
read more
Compute power of power k times % m
Given x, k and m. Compute (xxxx…k)%m, x is in power k times. Given x is always prime and m is greater than x....
read more
Minimize steps required to convert number N to M using arithmetic operators
Given two integers N and M, the task is to find the sequence of the minimum number of operations required to convert the number N into M such that in each operation N can be added (N = N + N), subtracted as (N = N – N), multiplied as (N = N*N), or divided as (N = N/N). If it is not possible to convert N into M then print “-1”....
read more
Sudo Placement 2 | Matrix Series
A Matrix series is defined as follows:...
read more
Find value of (n^1 + n^2 + n^3 + n^4) mod 5 for given n
You are given a function f(n) = (n1 + n2 + n3 + n4), you have to find the value of f(n) mod 5 for any given value of positive integer n. Note: n may be large enough, such that f(n) > 1018. Examples :...
read more
Find First element in AP which is multiple of given prime
Given the first term (A) and common difference (D) of an Arithmetic Progression, and a prime number (P). The task is to find the position of the first element in the given AP which is a multiple of the given prime number P.Examples:...
read more